﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Pannel.aspx.cs" Inherits="MultyLanguage.Pannel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Administration page</title>
        <link rel="Stylesheet" href="css/AdminPage.css" />
        <script type="text/javascript" src="scripts/jquery.js"></script>
        <style type="text/css">
            #btnSave
            {
                width: 78px;
            }
        </style>
    </head>
<body>      
        <form id="adminForm" runat="server">
        <asp:ListBox Rows = "1" ID="ListShowLanguage" CssClass="changeLang" 
            runat="server" Height="30px" Width="110px" AutoPostBack="True" 
            ontextchanged="ListShowLanguage_TextChanged">
        </asp:ListBox>
        <script type="text/javascript">
            $(document).ready(function()
            {
                //get text according to language
                $(".showlang").click(function()
                {
                    var ctrl = document.getElementById("controlsList").value;
                    var lang = document.getElementById("languagesList").value;
                    var page = document.getElementById("lstResource").value;
                    $.ajax({
                        url: "ajax_solution.aspx",
                        type: "POST",
                        dataType: "html",
                        processData: "false",
                        data: { "page":page,"control": ctrl,"language":lang},
                        success: function(result) 
                        {        
                            $("#txtValue").val(result);   
                        }   
                    });
                    
                });
                //save text for control
                $("#btnSave").click(function()
                {
                    var ctrl = document.getElementById("controlsList").value;
                    var lang = document.getElementById("languagesList").value;
                    var page = document.getElementById("lstResource").value;
                    var val = document.getElementById("txtValue").value;
                    $.ajax({
                        url: "ajax_solution.aspx",
                        type: "POST",
                        dataType: "html",
                        processData: "false",
                        data: { "page": page, "control": ctrl, "language": lang, "val": val },
                        success: function(result) 
                        {        
                             alert(result);
                        }
                    });
                });
            });
        </script>
            <div class="leftpanel">
                <asp:ListBox ID="controlsList" runat="server" class="showlang" AppendDataBoundItems="True"></asp:ListBox>

            </div><!--end leftpanel!-->
            
            <div class="rightpanel">
                <h2 id="targetSite" runat="server">www.somepage.com</h2>
                
                <ul id="operations_1">
                    <li>
                        <div id="btnExport" class="fakebutton" runat="server">
                            <img src="images/export.jpg" alt="Export to resources" class="left" />
                            <label id="lbexport">Export to resources</label>
                        </div>
                    </li>
                    <li>
                        <div id="btnImport" class="fakebutton" runat="server">
                            <img src="images/import.jpg" alt="Import from resources" class="left" />
                            <label id="lbimport">Import from resources</label>
                        </div>
                    </li>
                    <li>
                        <div id="btnCreateTable" class="fakebutton" runat="server">
                            <img src="images/createtable.jpg" alt="Create table" class="left" />
                            <label id="lbCreatetb">Create table</label>
                        </div>
                    </li>
                    <li>
                        <div id="btnBackup" class="fakebutton" runat="server">
                            <img src="images/backup.jpg" alt="Backup" class="left" />
                            <label>Backup</label>
                        </div>
                    </li>
                    <li>
                        <div id="btnRefresh" class="fakebutton" runat="server">
                            <img src="images/refresh.jpg" alt="Refresh page" class="left" />
                            <label id="lbrefresh">Refresh page</label>
                        </div>
                    </li>
                    <li>
                        <div id="btnReload" class="fakebutton" runat="server">
                            <img src="images/reload.jpg" alt="Reload resource" class="left" />
                            <label id="lbreload">Reload resource</label>
                        </div>
                    </li>
                </ul><!--end operations_1!-->
                <div class="clear"></div><br />
                
                <div id="resourceSet">
                    <label>Resource set:</label><br />
                    <asp:ListBox Rows="1"  ID="lstResource" runat="server"
                       
                        AppendDataBoundItems="True" AutoPostBack="True" 
                        ontextchanged="lstResource_TextChanged"></asp:ListBox>

                </div><!--end resourceSet!-->
                <div class="clear"></div><br />
                
                <div id="languages">
                    <label>Languages:</label><br />
                    <asp:ListBox ID="languagesList" runat="server" class="showlang"></asp:ListBox>
                </div><!--end languages!-->
                <div class="clear"></div><br />
                <div id="value">
                    <label>Value:</label><br />
                    <asp:TextBox ID="txtValue" runat="server"></asp:TextBox>
                    <script type="text/javascript">
                        function checkit(sender, e) {
                            if (e.Value.indexOf("<") >= 0) {
                                if (e.Value.indexOf(">") >= 0 && e.Value.indexOf("!") >= 0) {
                                    e.IsValid = false;
                                    document.getElementById("txtValue").value = document.getElementById("txtValue").value.replace(/</g, "");
                                    document.getElementById("txtValue").value = document.getElementById("txtValue").value.replace(/>/g, "");
                                    document.getElementById("validator").style.display = "block";
                                }
                            }
                            else {
                             alert("hello");
                                e.IsValid = true;
                                document.getElementById("validator").style.display = "none";
                            }
                        }
                    </script>
                    <asp:CustomValidator ID="validator" runat="server" Text="Cannot type special characters here" ControlToValidate="txtValue" ClientValidationFunction="checkit" EnableClientScript="true"></asp:CustomValidator>
                </div><!--end value!-->
                <div class="clear"></div><br />
                
                <div id="operations_2">
                    <input type="button" id="btnSave"  value="Save" title="" />&nbsp;&nbsp;&nbsp;
                    <input type="button" id="btnTranslate" value="Translate" title="" />
                </div><!--end operations_2!-->
                <div class="clear"></div><br />
                
                <div id="controlsSummary">
                    <label>Summary:</label><br />
                    <asp:ListBox ID="lstSummary" runat="server" Height="86px"></asp:ListBox>
                </div><!--end controlsSummary!-->
            </div><!--end rightpanel!-->
        </form>
    </body>
</html>
